#include "tire.h"
#include "../framework.h"

Vertexf Tire::vertices[] = { Vertexf(-1.0f,0.0f),Vertexf(-0.5f,-1.0f),
							 Vertexf(0.5f,-1.0f),Vertexf(1.0f,0.0f),
							 Vertexf(0.5f,1.0f),Vertexf(-0.5f,1.0f),
							 Vertexf(100.0f,0.0f)};

Tire::Tire()
	: SceneObject(){
	this->objVertices.vertices = vertices;
	this->objVertices.nVertices = nVertices;
	this->rotationAngle=0;
}

Tire::~Tire(){
}

void Tire::draw(){
	Framework& fr = Framework::instance();

	Colorf oldColor = fr.pipeline.getFillColor();
	fr.pipeline.rotate(this->rotationAngle);

	fr.pipeline.pushMatrix();
		fr.pipeline.setFillColor(Colorf(0.0f,0.0f,0.0f));
		fr.pipeline.escale(0.1f,0.1f);
		fr.pipeline.draw(Pipeline::CIRCLES,vertices+6,1);
	fr.pipeline.popMatrix();

	fr.pipeline.pushMatrix();
		fr.pipeline.setFillColor(Colorf(0.83f,0.83f,0.83f));
		fr.pipeline.escale(0.08f,0.08f);
		fr.pipeline.draw(Pipeline::CIRCLES,vertices+6,1);
	fr.pipeline.popMatrix();

	fr.pipeline.pushMatrix();
		fr.pipeline.setFillColor(Colorf(0.0f,0.0f,0.0f));
		fr.pipeline.escale(0.01f,0.01f);
		fr.pipeline.draw(Pipeline::CIRCLES,vertices+6,1);
	fr.pipeline.popMatrix();

	for(unsigned int c=0;c<12;c++){
		fr.pipeline.setFillColor(Colorf(0.0f,0.0f,0.0f));
		fr.pipeline.pushMatrix();
			fr.pipeline.rotate((PI/4)*c);
			fr.pipeline.translate(6,0);
			fr.pipeline.draw(Pipeline::POLYGON,vertices,6);
		fr.pipeline.popMatrix();
	}
	fr.pipeline.setFillColor(oldColor);
}

